﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Citi.HeadCount.Domain;
using Citi.HeadCount.Domain.Repository;

namespace Citi.HeadCount.WebUI.Models
{
    public class TypeResultViewModel
    {
        public int Id { get; set; }
        public int Type { get; set; }
        public string TypeDescription { get; set; }
        public string Value { get; set; }
        public bool Active { get; set; }
        public DateTime ReferenceDate { get; set; }
        public DateTime LastUpdate { get; set; }

        public static TypeResultViewModel CreateModel(TypeResult domain)
        {
            return new TypeResultViewModel { Id = domain.Id, Type = (int)domain.Type, Value = domain.Value, TypeDescription = domain.Type.GetDescription() };
        }

        public static List<TypeResultViewModel> CreateModel(List<TypeResult> domains)
        {
            return domains.Select(CreateModel).ToList();
        }

        public static TypeResult CreateDomain(TypeResultViewModel model)
        {
            return new TypeResult { Type = (TypeResultType)model.Type, Value = model.Value, Active = true, ReferenceDate = DateTime.Today, LastUpdate = DateTime.Today};
        }

        public static List<TypeResult> CreateDomain(List<TypeResultViewModel> models)
        {
            return models.Select(CreateDomain).ToList();
        }

    }
}